package java_thinking.unit_17._17_2_6;

import java.util.Map;
import java.util.Set;
import java.util.TreeMap;
import java.util.TreeSet;

import static java_thinking.unit_17._17_2_6.Countries.capitals;
import static java_thinking.unit_17._17_2_6.Countries.names;

/**
 * @Desc:   生成一个Map和Set，使其包含所有以字母A开头的国家
 * @author: cww
 * @DateTime: 2019-04-14 22:43
 */

public class E02_ACountries {
    public static void main(String[] args) {
        TreeMap<String,String> map = new TreeMap<>(capitals());
        TreeSet<String> set = new TreeSet<>(names());
        String b = null;
        for (String s : map.keySet()) {
            if (s.startsWith("B")) {
                b = s;
                break;
            }
        }
        Map<String,String> aMap = map.headMap(b);
        Set<String> aSet = set.headSet(b);
        System.out.println("aMap= "+aMap);
        System.out.println("aSet= " + aSet);
    }
}
